//
//  HomeTipsView.m
//  Ginix
//
//  Created by 冯志强 on 2025/2/24.
//

#import "HomeTipsView.h"

@interface HomeTipsView()
@property (nonatomic,strong) UILabel * nameLabel;
@property (nonatomic,strong) UILabel * infoLabel;
@property (nonatomic,strong) UIButton * enterBtn;
@property (nonatomic,strong) UIButton * cancenBtn;
@end

@implementation HomeTipsView

-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        self.location = CenterStyle;
        [self setSubViewLayout];
    }
    return self;
}

-(void)setSubViewLayout{
    
    self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
    self.contentView.frame = CGRectMake(40 *  FMScaleX, (HEIGHT - 150 * FMScaleX) / 2, WIDTH - 80 * FMScaleX, 150 * FMScaleX );
    [self.contentView setCornerRadius: 8 * FMScaleX];
    self.contentView.backgroundColor = UIColor.whiteColor;
    
    [self.contentView addSubview:self.nameLabel];
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_offset(CGSizeMake(240 * FMScaleX, 25 * FMScaleX));
        make.centerX.equalTo(@0);
        make.top.mas_offset(24 * FMScaleX);
    }];
    [self.contentView addSubview:self.infoLabel];
    [_infoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(@0);
        make.width.mas_offset(240 * FMScaleX);
        make.top.equalTo(self.nameLabel.mas_bottom).offset(10 * FMScaleX);
    }];
    [self.contentView addSubview:self.cancenBtn];
    [_cancenBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.equalTo(@0);
        make.size.mas_offset(CGSizeMake(140 * FMScaleX, 48 * FMScaleX));
    }];
    [self.contentView addSubview:self.enterBtn];
    [_enterBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.bottom.equalTo(self.cancenBtn);
        make.right.equalTo(@0);
    }];
}

-(void)startAnimationWithTitle:(NSString *)title info:(NSString *)info{
    
    [super startAnimation];
    self.nameLabel.text = title;
    self.infoLabel.text = info;
    
}

-(void)cancenBtnAction{
    
    [self closeView];
    
}
-(void)enterBtnAction{
    
    if (self.enterdBtnBlock) {
        self.enterdBtnBlock();
        [self closeView];
    }    
}

-(UILabel *)nameLabel{
    
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.font = Medium(17);
        _nameLabel.textColor = RDRGB(0x171A1D);
        _nameLabel.text = @"是否绑定";
        _nameLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _nameLabel;
}
-(UILabel *)infoLabel{
    
    if (!_infoLabel) {
        _infoLabel = [[UILabel alloc]init];
        _infoLabel.font = Regular(15);
        _infoLabel.textColor =RDRGB(0x666666);
        _infoLabel.text = @"是否绑定当前戒指的到当前账号?";
        _infoLabel.numberOfLines = 0;
        _infoLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _infoLabel;
}

-(UIButton *)cancenBtn{
    
    if (!_cancenBtn) {
        _cancenBtn = [[UIButton alloc]init];
        [_cancenBtn setTitle:@"取消" forState:UIControlStateNormal];
        _cancenBtn.titleLabel.font = Regular(17);
        [_cancenBtn setBackgroundColor:RDRGB(0xF7F6F9)];
        [_cancenBtn setTitleColor:RDRGB(0x666666) forState:UIControlStateNormal];
        [_cancenBtn addTarget:self action:@selector(cancenBtnAction ) forControlEvents:UIControlEventTouchUpInside];
    }
    return _cancenBtn;
}

-(UIButton *)enterBtn{
    
    if(!_enterBtn){
        _enterBtn = [[UIButton alloc]init];
        [_enterBtn setTitle:@"确定" forState:UIControlStateNormal];
        [_enterBtn setTitleColor:RDRGB(0xAD7D62) forState:UIControlStateNormal];
        [_enterBtn addTarget:self action:@selector(enterBtnAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _enterBtn;
    
}
@end
